<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script src="utils/jquery-2.2.4.js"></script>
<script src="utils/失败重连.js"></script>

<script>

  const BASE_URL = `http://localhost:3000`;

  const changeParams = (obj) => Object.keys(obj)
    .map((item, index) => index === 0 ?
      `?${item}=${obj[item]}` :
      `&${item}=${obj[item]}`).join('');

  function requestGET(url, params) {
    let str = changeParams(params);
    return new Promise((resolve, reject) => {
      $.ajax({
        url: `${BASE_URL}${url}${str}`,
        type: "get",
        dataType: "json",//数据类型
        success: function (res) {
          resolve(res);
        },
        error(err) {
          reject(undefined);
        }
      });
    })
  }

  async function getResult() {
    // let res = await requestGET('/login', {});
    let res1 = await reduceRequest(requestGET, {url: '/login', args: {}}, 15, 1000);
    console.log(res1);
  }

  getResult();
</script>

</body>
</html>
